<?php
/**
 * Created by PhpStorm.
 * Author: 黑瞎子
 * Date: 2018/3/14
 * Time: 19:37
 */

namespace app\api\model;


use think\Model;

class Banner extends Model
{
    //隐藏的字段
    protected $hidden = ['delete_time', 'update_time'];

    //关联BannerItem模型
    public function items(){
        return $this->hasMany('BannerItem', 'banner_id', 'id');
    }

    public static function getBannerByID($id){
        $banner = self::with(['items', 'items.img'])->find($id);
        return $banner;
    }
}